package com.shop.vo;

import com.shop.pojo.ums.Ums_Member_Receive_Address;
import com.shop.vo.OrderItemVo;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
public class OrderConfirmVo {
    //收货地址
    @Setter
    @Getter
    List<Ums_Member_Receive_Address> address;

    //所有选中购物项
    @Setter
    @Getter
    List<OrderItemVo> items;
    //发票记录

    //优惠券信息
    @Setter
    @Getter
    Integer integration;



    @Setter
    @Getter
    Map<Long,Boolean> stocks;




    //防重令牌
    @Setter
    @Getter
    String orderToken;

    public Integer getCount(){
        Integer i=0;
        if (items != null) {
            for (OrderItemVo item : items) {
                i+=item.getCount();
            }
        }
        return i;
    }

    //订单总额
//    @Setter
//    @Getter
//    BigDecimal total;

    public BigDecimal getTotal() {
        //默认总结为0
        BigDecimal sum = new BigDecimal("0");
        if (items != null) {
            for (OrderItemVo item : items) {
                //当前价格乘以当前数量
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }

        return sum;
    }

    //应付价格
    //@Setter @Getter
    // BigDecimal payPrice;
    public BigDecimal getpayPrice() {

        return getTotal();
    }


}
